package com.xingxue.service;

import com.xingxue.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
@Slf4j
public class CheckService {

    public boolean check(Authentication authentication, HttpServletRequest request) {
        String uri = request.getRequestURI().replaceAll(request.getContextPath(),"");
        log.debug("当前的URI地址为：[" + uri+"]");
        User user = (User) authentication.getPrincipal();
        return user.containsUrl(uri);
    }
}
